package com.sybkl.bigdatastudentmybatisplus.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.sybkl.bigdatastudentmybatisplus.entity.Subject;
import com.sybkl.bigdatastudentmybatisplus.service.SubjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/subject")
public class SubjectController {

    @Autowired
    private SubjectService subjectService;

    @GetMapping("/all")
    public List<Subject> findAllScore() {
        return subjectService.list();
    }

    @GetMapping("/{id}")
    public List<Subject> findScoreById(@PathVariable String id) {
        QueryWrapper<Subject> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("student_id", id);
        return subjectService.list(queryWrapper);
    }

}
